package org.example.controller;

import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.Controller;

@Component
public class WelcomeController implements Controller {
    //请求路径：/welcome
    @RequestMapping
    public String welcome() {
        return "Welcome!";
    }

    //请求路径：/welcome/hello
    @RequestMapping("/hello")
    public String hello() {
        return "Hello!";
    }

    @Override
    public ModelAndView handleRequest(HttpServletRequest request, HttpServletResponse response) throws Exception {
        ModelAndView mav = new ModelAndView("welcome");
        return mav;
    }
}
